<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="../js/user-info.js"></script>
    <script src="../js/queryByName.js"></script>
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">导航</a>
        <a>
          <cite>学生信息</cite></a>
      </span>
    <a class="layui-btn layui-btn-primary layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:38px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
            <!--          <input class="layui-input" placeholder="开始日" name="start" id="start">-->
            <!--          <input class="layui-input" placeholder="截止日" name="end" id="end">-->
            <input type="text" id="userid" placeholder="请输入用户Id" autocomplete="off" class="layui-input">
            <button class="layui-btn" onclick="findById()"><i class="layui-icon">&#xe615;</i></button>
            <input type="text" id="username" placeholder="请输入用户姓名" autocomplete="off" class="layui-input">
            <button class="layui-btn" onclick="queryUserByName()"><i class="layui-icon">&#xe615;</i></button>
        </div>
    </div>
    <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delSome()"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show('添加用户','user-add.html')"><i class="layui-icon"></i>添加</button>
        <!--        <span class="x-right" style="line-height:40px">共有数据：88 条</span>-->
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <label>
                    <input type="checkbox" onclick="checkAll(this)"/>
                </label>
            </th>
            <th>ID</th>
            <th>姓名</th>
            <th>密码</th>
            <th>性别</th>
            <th>院系</th>
            <th>角色</th>
            <th>操作</th>
        </thead>
        <tbody id="users">
        </tbody>
    </table>
    <!--      <div class="page">-->
    <!--        <div>-->
    <!--          <a class="prev" href="">&lt;&lt;</a>-->
    <!--          <a class="num" href="">1</a>-->
    <!--          <span class="current">2</span>-->
    <!--          <a class="num" href="">3</a>-->
    <!--          <a class="num" href="">489</a>-->
    <!--          <a class="next" href="">&gt;&gt;</a>-->
    <!--        </div>-->
    <!--      </div>-->

</div>
<script>
    function userInfo() {
        $.post('http://localhost:8080/user/findAllUsers', function (result) {
            let res = result.object;
            let str = "";
            for (let i = 0; i < res.length; i++) {
                str += "<tr><td>\n" +
                    "<input type='checkbox' name='checkbox' value='" + res[i].userid + "'/>\n" +
                    "</td>";
                str += "<td>" + res[i].userid + "</td>";
                str += "<td>" + res[i].username + "</td>";
                str += "<td>" + res[i].password + "</td>";
                str += "<td>" + res[i].sex + "</td>";
                str += "<td>" + res[i].faculty + "</td>";
                if (res[i].priority == 2) {
                    str += "<td>管理员</td>";
                } else if (res[i].priority == 1) {
                    str += "<td>教师</td>";
                } else if (res[i].priority == 0) {
                    str += "<td>学生</td>";
                } else {
                    alert("请求出错");
                }
                str += "<td class=\"td-manage\">\n" +
                    "<a title='编辑' onclick=\"user_edit_show('编辑','user-edit.html'," + res[i].userid + ")\" href='javascript:;'>\n" +
                    "<i class=\"layui-icon\">&#xe642;</i>\n" +
                    "</a>\n" +
                    "<a title='删除' onclick='user_del(this," + res[i].userid + ")' href='javascript:;'>\n" +
                    "<i class=\"layui-icon\">&#xe640;</i>\n" +
                    "</a>\n" +
                    "</td></tr>";
            }
            $("#users").html(str);
        });
    }
</script>
</body>
</html>